package tech.aistar.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;


@Component
public  class EmailSendUtil {
    @Autowired
    private  JavaMailSender sender;

        public void emailSend(String EmaiFrom, String EmailSubject, String EmailText, String EmailTo){
            //用来封装邮件的相关信息
            SimpleMailMessage msg = new SimpleMailMessage();

            //需要和你配置文件中的mail中的username保持一致
//            msg.setFrom("1807074188@qq.com");
//            msg.setSubject("邮箱测试");
//            msg.setText("验证码:5555");
//            //邮箱的接收方
//            msg.setTo("1807074188@qq.com");
            msg.setFrom(EmaiFrom);
            msg.setSubject(EmailSubject);
            msg.setText(EmailText);
            msg.setTo(EmailTo);

            //发送
            sender.send(msg);
        }
}
